<link rel="stylesheet" type="text/css" href="/css/comment.css" />
<link rel="stylesheet" type="text/css" href="/css/comment_1.css" />	
<script language="javascript" type="text/javascript" src="/js/jquery_elastic.js"></script>

<?php if($_SESSION['config_template']=='layoutmain_web1') {?>
	<div class="product-collateral">
		<div id="customer-reviews" class="box-collateral box-reviews">
				<div class="form-add">
					<h2><?php echo $textlist;?> (<?php if(isset($countcomment)) echo $countcomment;?>)</h2>
					<?php if(isset($countcomment) && $countcomment >0) {?>
											
					<?php if (isset($datacomment))
					{
						foreach($datacomment as $comment1)
						{?>
						<div class="hoidap_reply">
							<div id="reply_<?php echo $comment1['comment_id'];?>">
							<div style="width: 8%" class="user">
							<div class="avatar_xx_small"><a class="tooltip_user" iuse="828180"
								href="<?php echo $comment1['link_user'];?>" rel="nofollow"> <img
								width="50" height="47" maxwidth="50" maxheight="50"
								src="<?php echo $comment1['user_image'];?>"></a></div>
							<div class="loginname"><a class="text_link"
								title="<?php echo $comment1['user_name'];?>"
								href="<?php echo $comment1['link_user'];?>" rel="nofollow"><?php echo $comment1['user_name'];?></a></div>
							<div style="width: 70%; text-align: center;" class="opt end">
							<?php if($comment1['yahoo']!=null) {?>
							<a title="<?php echo $comment1['yahoo'];?>"
								href="ymsgr:SendIM?<?php echo $comment1['yahoo'];?>"><img
								src="http://opi.yahoo.com/online?u=<?php echo $comment1['yahoo'];?>&amp;t=5&amp;l=us"></a>
							<?php } ?>
							<?php if(isset($comment1['skype'])) {?>
							<a title="<?php echo $comment1['skype'];?>"
								href="skype:<?php echo $comment1['skype'];?>?chat"><img
								src="/images/icon_skype.gif"></a></div>
							<?php }?>
							</div>
							
							<div style="width: 90%" class="data">
							<div style="background: url(/images/arrow.gif) no-repeat;" class="arrow"></div>
							<div class="descriptionCM">
							<div class="reply_description"><?php echo ($comment1['description']);?></div>
							<br>
							<div class="break_module_line"></div>
							</div>
							
							<div class="information">
							
							<div class="magin_top"><span><?php echo $textcreatedday  ?></span> <?php echo $comment1['created_date'];?> &nbsp; <span
								class="sep"> |</span>&nbsp;<span><?php echo $textupdatedday  ?></span> <?php echo $comment1['updated_date'];?> 
							<?php if(isset($permission) && $permission=="true")  {?>
							<input type="button"
								style="background-image: url('/images/button_del.png'); border: none; width: 20px; height: 20px;"
								value="" onclick="delComment(<?php echo "'".$comment1['comment_id']."','".$comfirm_delete."'";?>)"
								id="del_<?php echo $comment1['comment_id']; ?>">
							<?php  }?>
							</div>
							</div>
							</div>
							
							<div class="break_content_line"></div>
							
							</div>
							
						</div>
						<?php }}?>
						<?php } else {?>
							<div class="hoidap_reply"><span><?php  echo $textnocm?></span></div>
							<?php }?>
				</div>
				<div class="buttons-set">
					<button class="button" title="Submit Review" type="submit" onclick='showreply()'><span><span><?php echo $textanswer?></span></span></button>
				</div>
				<div id="reply" class="hidden">
					<div class="module_larger_title" id="product_reply">
						<div class="L"></div>
						<div class="C"><a lang="vi" href="#product_technical" ><?php echo $textsend ?></a>
						 <span id="charleft12" class="" style="margin-left: 20px;font-size: 16px;font-weight: bold;"> <?php  echo $text_remain_char ?> : <span id="charLeft">2000</span> </span>
						</div>
						<div class="R"></div>
					</div>
					<div class="module_larger pro_reply">
						<?php if(isset($logged) && $logged==1 ) {?>
						<div style="margin-left:10px;margin-top:5px;margin-right:5px;float:left;height:auto;">
							<img width="50" height="47" src="<?php echo $current_user_image;?>" maxheight="50" maxwidth="50">
						</div>
						<?php }?>
						<div class="parent_form">
							<form action="/comment/comment/postcomment" id="reply_form1" name="product_reply_0" method="post" onSubmit="checkFormReply('0',<?php echo "'".$alert2."','".$alert3."','".$alert4."'";?>); return false;">
								<textarea style="height:50px; max-height:300px;" class="<?php if(isset($logged) && $logged==1) { echo "form_control1"; } else { echo "form_control";  }?> form_control_null_value" name="content" id="txtcontent" onfocus="checkReplyFocus($(this),<?php echo "'".$alert1."'";?>)" onblur="checkReplyBlur($(this))"><?php echo $text_text?></textarea>
								<div class="reply_button hidden"><input type="text" class="form_control form_control_null_value" value="<?php echo  $text_safe_key?>" name="security_code" onblur="checkSecurityBlur($(this))" onfocus="checkSecurityFocus($(this))" id="security_code" style="" /><a onclick="" style="cursor:pointer"><img id="captchaShow" src="<?php echo "/captcha/images/".$captchaID.".jpg"?>" /><input type="hidden" id="code" name="code" value="<?php echo $captchaID?>" />
								</div><input type="hidden" name="thing_id" value="<?php echo $_GET['id'];?>" /><input type="hidden" name="estore_id" value="459" /><input type="hidden" name="parent_id" value="0" /><input type="hidden" name="action" value="execute" />
								<div style="margin-top:10px;padding-top:10px" class="buttons-set">
									<button class="button" title="Submit Review" type="submit"><span><span><?php echo $textbtnsend?></span></span></button>
								</div>
							</form>
						</div>
						<div class="reply_listing"></div>
					</div>
				</div>
		</div>
	</div>
<?php } else if($_SESSION['config_template']=='layoutmain_web2') { ?>
	
	<div style="clear: both;"></div>
<div class="hoidap_reply">
		<?php if(isset($countcomment) && $countcomment >0) {?>
			<p><?php echo $textlist	 ?> <b class="count">(<?php if(isset($countcomment)) echo $countcomment;?>)</b></p>
			<div class="line"><hr></div><br/>
			<?php if (isset($datacomment))
			{
				foreach($datacomment as $comment1)
				{?>
				<div id="reply_<?php echo $comment1['comment_id'];?>">
				<div class="user">
					<div class="avatar_xx_small"><a rel="nofollow" href="<?php echo $comment1['link_user'];?>" iuse="828180" class="tooltip_user">
					<img width="50" height="47" src="<?php echo $comment1['user_image'];?>" maxheight="50" maxwidth="50"></a></div>
					<div class="loginname"><a rel="nofollow" href="<?php echo $comment1['link_user'];?>" title="<?php echo $comment1['user_name'];?>" class="text_link"><?php echo $comment1['user_name'];?></a></div>
					<div class="opt end">
					<?php if($comment1['yahoo']!=null) {?>
					<a href="ymsgr:SendIM?<?php echo $comment1['yahoo'];?>" title="<?php echo $comment1['yahoo'];?>"><img src="http://opi.yahoo.com/online?u=<?php echo $comment1['yahoo'];?>&amp;t=5&amp;l=us"></a>
					<?php } ?>
					<?php if(isset($comment1['skype'])) {?>
					<a href="skype:<?php echo $comment1['skype'];?>?chat" title="<?php echo $comment1['skype'];?>"><img src="/images/icon_skype.gif"></a></div>
					<?php }?>
				</div>
				
				<div class="data">
					<div class="arrow"></div>
					<div class="descriptionCM">
					<div class="reply_description">
					<?php echo ($comment1['description']);?>
					</div>
					<br><div class="break_module_line"></div>
					</div>
					
					<div class="information">
					
					<div class="magin_top">
					<span><?php echo $textcreatedday  ?></span> <?php echo $comment1['created_date'];?>&nbsp; <span class="sep"> |</span>&nbsp;<span><?php echo $textupdatedday  ?></span> <?php echo $comment1['updated_date'];?> 
					
					<?php if(isset($permission) && $permission=="true")  {?>
					<input type="button" id="del_<?php echo $comment1['comment_id']; ?>" onclick="delComment(<?php echo "'".$comment1['comment_id']."','".$comfirm_delete."'";?>)"  value="" style="background-image: url('/images/button_del.png'); border: none; width:20px;height:20px;margin-top:11px;">
					<?php  }?>
					
					</div>
					</div>
				</div>
				
				<div class="break_content_line" ></div>
		
			</div>
		<?php }}?>
		<?php } else {?>
		<p ></p>
		<div class="line"><hr></div><br /><br />
		<div style="text-align: center;"><span><?php  echo $textnocm?></span></div>
		<?php }?>
		
		<!-- <div style="text-align: center;"><?php echo $pagination; ?></div> -->
		           
		<a onclick='showreply()' href="javascript:;" class="reply_btn"><span><?php echo $textanswer?></span></a>
</div>
<div id="reply" class="hidden">
	<div class="module_larger_title" id="product_reply">
		<div class="L"></div>
		<div class="C"><a lang="vi" href="#product_technical"><?php echo $textsend ?></a>
		 <span id="charleft12" class="hidden" style="margin-left: 20px;"> <?php  echo $text_remain_char ?> : <span id="charLeft">2000</span> </span>
		</div>
		<div class="R"></div>
	</div>
	<div class="module_larger pro_reply">
		<?php if(isset($logged) && $logged==1 ) {?>
		<div style="margin-left:10px;margin-top:5px;margin-right:5px;float:left;height:auto;">
			<img width="50" height="47" src="<?php echo $current_user_image;?>" maxheight="50" maxwidth="50">
		</div>
		<?php }?>
		<div class="parent_form">
			<form action="/comment/comment/postcomment" id="reply_form1" name="product_reply_0" method="post" onSubmit="checkFormReply('0',<?php echo "'".$alert2."','".$alert3."','".$alert4."'";?>); return false;"><textarea class="<?php if(isset($logged) && $logged==1) { echo "form_control1"; } else { echo "form_control";  }?> form_control_null_value" name="content" id="txtcontent" onfocus="checkReplyFocus($(this),<?php echo "'".$alert1."'";?>)" onblur="checkReplyBlur($(this))"><?php echo $text_text?></textarea><div class="reply_button hidden"><input type="text" class="form_control form_control_null_value" value="<?php echo  $text_safe_key?>" name="security_code" onblur="checkSecurityBlur($(this))" onfocus="checkSecurityFocus($(this))" id="security_code" style="" /><a onclick="" style="cursor:pointer"><img id="captchaShow" src="<?php echo "/captcha/images/".$captchaID.".jpg"?>" /><input type="hidden" id="code" name="code" value="<?php echo $captchaID?>" /><input type="submit" class="form_button" value="<?php echo $textbtnsend?>" /></div><input type="hidden" name="thing_id" value="<?php echo $_GET['id'];?>" /><input type="hidden" name="estore_id" value="459" /><input type="hidden" name="parent_id" value="0" /><input type="hidden" name="action" value="execute" /></form>
		</div>
		<div class="reply_listing"></div>
	</div>
</div>
<?php } else { ?>
<div style="clear: both;"></div>
<div class="hoidap_reply">
		<?php if(isset($countcomment) && $countcomment >0) {?>
			<p><?php echo $textlist	 ?> <b class="count">(<?php if(isset($countcomment)) echo $countcomment;?>)</b></p>
			<div class="line"><hr></div><br/>
			<?php if (isset($datacomment))
			{
				foreach($datacomment as $comment1)
				{?>
				<div id="reply_<?php echo $comment1['comment_id'];?>">
				<div class="user">
					<div class="avatar_xx_small"><a rel="nofollow" href="<?php echo $comment1['link_user'];?>" iuse="828180" class="tooltip_user">
					<img width="50" height="47" src="<?php echo $comment1['user_image'];?>" maxheight="50" maxwidth="50"></a></div>
					<div class="loginname"><a rel="nofollow" href="<?php echo $comment1['link_user'];?>" title="<?php echo $comment1['user_name'];?>" class="text_link"><?php echo $comment1['user_name'];?></a></div>
					<div class="opt end">
					<?php if($comment1['yahoo']!=null) {?>
					<a href="ymsgr:SendIM?<?php echo $comment1['yahoo'];?>" title="<?php echo $comment1['yahoo'];?>"><img src="http://opi.yahoo.com/online?u=<?php echo $comment1['yahoo'];?>&amp;t=5&amp;l=us"></a>
					<?php } ?>
					<?php if(isset($comment1['skype'])) {?>
					<a href="skype:<?php echo $comment1['skype'];?>?chat" title="<?php echo $comment1['skype'];?>"><img src="/images/icon_skype.gif"></a></div>
					<?php }?>
				</div>
				
				<div class="data">
					<div class="arrow"></div>
					<div class="descriptionCM">
					<div class="reply_description">
					<?php echo ($comment1['description']);?>
					</div>
					<br><div class="break_module_line"></div>
					</div>
					
					<div class="information">
					
					<div class="magin_top">
					<span><?php echo $textcreatedday  ?></span> <?php echo $comment1['created_date'];?>&nbsp; <span class="sep"> |</span>&nbsp;<span><?php echo $textupdatedday  ?></span> <?php echo $comment1['updated_date'];?> 
					
					<?php if(isset($permission) && $permission=="true")  {?>
					<input type="button" id="del_<?php echo $comment1['comment_id']; ?>" onclick="delComment(<?php echo "'".$comment1['comment_id']."','".$comfirm_delete."'";?>)"  value="" style="background-image: url('/images/button_del.png'); border: none; width:20px;height:20px;margin-top:11px;">
					<?php  }?>
					
					</div>
					</div>
				</div>
				
				<div class="break_content_line" ></div>
		
			</div>
		<?php }}?>
		<?php } else {?>
		<p ></p>
		<div class="line"><hr></div><br /><br />
		<div style="text-align: center;"><span><?php  echo $textnocm?></span></div>
		<?php }?>
		
		<!-- <div style="text-align: center;"><?php echo $pagination; ?></div> -->
		           
		<a onclick='showreply()' href="javascript:;" class="reply_btn"><span><?php echo $textanswer?></span></a>
</div>
<div id="reply" class="hidden">
	<div class="module_larger_title" id="product_reply">
		<div class="L"></div>
		<div class="C"><a lang="vi" href="#product_technical"><?php echo $textsend ?></a>
		 <span id="charleft12" class="hidden" style="margin-left: 20px;"> <?php  echo $text_remain_char ?> : <span id="charLeft">2000</span> </span>
		</div>
		<div class="R"></div>
	</div>
	<div class="module_larger pro_reply">
		<?php if(isset($logged) && $logged==1 ) {?>
		<div style="margin-left:10px;margin-top:5px;margin-right:5px;float:left;height:auto;">
			<img width="50" height="47" src="<?php echo $current_user_image;?>" maxheight="50" maxwidth="50">
		</div>
		<?php }?>
		<div class="parent_form">
			<form action="/comment/comment/postcomment" id="reply_form1" name="product_reply_0" method="post" onSubmit="checkFormReply('0',<?php echo "'".$alert2."','".$alert3."','".$alert4."'";?>); return false;"><textarea class="<?php if(isset($logged) && $logged==1) { echo "form_control1"; } else { echo "form_control";  }?> form_control_null_value" name="content" id="txtcontent" onfocus="checkReplyFocus($(this),<?php echo "'".$alert1."'";?>)" onblur="checkReplyBlur($(this))"><?php echo $text_text?></textarea><div class="reply_button hidden"><input type="text" class="form_control form_control_null_value" value="<?php echo  $text_safe_key?>" name="security_code" onblur="checkSecurityBlur($(this))" onfocus="checkSecurityFocus($(this))" id="security_code" style="" /><a onclick="" style="cursor:pointer"><img id="captchaShow" src="<?php echo "/captcha/images/".$captchaID.".jpg"?>" /><input type="hidden" id="code" name="code" value="<?php echo $captchaID?>" /><input type="submit" class="form_button" value="<?php echo $textbtnsend?>" /></div><input type="hidden" name="thing_id" value="<?php echo $_GET['id'];?>" /><input type="hidden" name="estore_id" value="459" /><input type="hidden" name="parent_id" value="0" /><input type="hidden" name="action" value="execute" /></form>
		</div>
		<div class="reply_listing"></div>
	</div>
</div>
 <?php } ?>
<script type="text/javascript">
var a = 2000;
var check=false;
var defValReply= "<?php echo $text_text?>";
var defValSecurity="<?php echo  $text_safe_key?>";

	function formReply(parent_id)
	{
		var strReturn ="";
		strReturn = '<form action="/comment/comment/postcomment" id="reply_form1" name="product_reply_' + parent_id + '" method="post" onSubmit="checkFormReply(\'' + parent_id + '\'); return false;">' +'<textarea class="<?php if(isset($logged) && $logged==1) { echo "form_control1"; } else { echo "form_control";  }?> form_control_null_value" name="content" id="txtcontent" onfocus="checkReplyFocus($(this))" onblur="checkReplyBlur($(this))">' + defValReply + '</textarea>' +'<div class="reply_button hidden">' +'<input type="text" class="form_control form_control_null_value" value="Nhập mã số an toàn" name="security_code" onblur="checkSecurityBlur($(this))" onfocus="checkSecurityFocus($(this))" id="security_code" style="" /><a onclick="" style="cursor:pointer"><img id="captchaShow" src="<?php echo "/captcha/images/".$captchaID.".jpg"?>" /><input type="hidden" id="code" name="code" value="<?php echo $captchaID?>" />' +'<input type="submit" class="form_button" value="Gửi phản hồi" />' +'</div>' +'<input type="hidden" name="thing_id" value="<?php echo $_GET['id'];?>" />' +'<input type="hidden" name="estore_id" value="459" />' +'<input type="hidden" name="parent_id" value="' + parseInt(parent_id) + '" />' +'<input type="hidden" name="action" value="execute" />' +'</form>';
		return strReturn;
	}
	function showreply()
	{
		if(check==false)
		{
			$("#reply").removeClass("hidden");
			check=true;
		}
		else
		{
			check=false;
			$("#reply").addClass("hidden");
		}	
	}
	function checkSecurityFocus(ob)
	{
			if(ob.val() == defValSecurity) 
				ob.val("");
	}
	function checkSecurityBlur(ob)
	{
			if(ob.val() == ""){
			ob.val(defValSecurity);
			ob.addClass("form_control_null_value");
			}
			
	}
	function checkReplyFocus(ob, alert1){
		<?php if(isset($logged) && $logged==0) {?>
			alert(alert1);
			ob.blur();
			return;
		<?php } else { ?>
			ob.removeClass("form_control_null_value");
			if(ob.val() == defValReply) 
				ob.val("");
				ob.next(".reply_button").removeClass("hidden");
				$("#charleft12").removeClass("hidden");
		<?php } ?>
	}
				
	function checkReplyBlur(ob)
	{if(ob.val() == ""){
			ob.val(defValReply);ob.addClass("form_control_null_value");
			ob.next(".reply_button").addClass("hidden");}
			$("#charleft12").addClass("hidden");
	}
	function checkFormReply(parent_id, alert2, alert3, alert4)
	{
			eval("frm= document.product_reply_" + parent_id + ";");
			if($.trim(frm.content.value) == ""){
				alert(alert2);
				frm.content.focus();return false;
				}
			
			else if($.trim(frm.security_code.value) == "" || $.trim(frm.security_code.value) == defValSecurity ){
				alert(alert3);
				frm.security_code.focus();return false;
				}
			else
			{

				if (window.XMLHttpRequest)
				{// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp=new XMLHttpRequest();
				}
				else
				{// code for IE6, IE5
					xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4 && xmlhttp.status==200)
					{
						if(xmlhttp.responseText == "-1")
							{
								alert(alert4);
								frm.content.focus();
								frm.security_code.value= "";
							
							}
						else 
						{

							window.location="";
						}
					}
				}
				xmlhttp.open("GET","/comment/comment/postcomment?"+$("#reply_form1").serialize(),true);
				xmlhttp.send();
				return false;
			}
		}
		
		$(function(){$("form[name^='product_reply'] textarea").elastic();});

		$(document).ready(function() {  
            $('#txtcontent').keyup(function() {  
                var len = this.value.length;  
                if (len >= 2000) {  
                    this.value = this.value.substring(0, 2000);  
                }  
				 a = 2000 - len;
				if(a<0) a = 0;
                $('#charLeft').text(a);  
                
            });  
        });  

        function jsonPage(url) {
        	if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp=new XMLHttpRequest();
			}
			else
			{// code for IE6, IE5
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					var temp = xmlhttp.responseText.substring(0, xmlhttp.responseText.length-3)
					$(".hoidap_reply").html(temp);
				}
			}
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send();
			return false;
            
        }
<?php if(isset($logged)&& $logged =="1" && isset($permission) && $permission=="true")  {?>	
function delComment(id, text_confirm)
{
	var sp_id=id;
	var confirmed=confirm(text_confirm);
	if(confirmed==true)
	{
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		
		}
		else
		{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange = function()
		{	if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			if(xmlhttp.responseText==-1)
				alert(<?php echo "'".$textError2."'";?>);
			else
				window.top.location.reload();
			}
		};
	
		var url = "/comment/comment/delete?id="+sp_id;
		xmlhttp.open("GET",url,true);	
		xmlhttp.send();
	}
	return false;
}		
<?php } ?>	
</script>

<div style="clear:both;"></div>